import React from "react";
import { Descriptions } from "antd";
import type { DetailFieldConfig } from "../../global.ts";
// 实际数据的类型定义
interface Data {
  [key: string]: any;
}

// DetailView 组件
const DetailView: React.FC<{
  detailFieldConfig: DetailFieldConfig[];
  data: Data;
}> = ({ detailFieldConfig, data }) => {
  return (
    <Descriptions column={2} layout="horizontal">
      {detailFieldConfig.map((item, index) => (
        <Descriptions.Item key={index} label={item.title} span={item.span ?? 1}>
          {item.render
            ? item.render(data[item.dataIndex], data)
            : data[item.dataIndex]}
        </Descriptions.Item>
      ))}
    </Descriptions>
  );
};

export default DetailView;
